home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / viewkit / xcontact / lib / OkArgs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  1.8 KB  |  79 lines

  1. /*
  2.  * Copyright (C) 1992, 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. #ifndef OKARGS_H
  18. #define OKARGS_H
  19.  
  20. //
  21. // OkArgs.h
  22. //
  23. //      See Class Definition.
  24. //
  25.  
  26. //
  27. // $Revision: 1.2 $
  28. //
  29. // OkArgs.h -    a C++ facility for build Widget argument lists for XtSetValues.
  30. //        The main advantages of using OkArgs over other coding
  31. //        conventions for creating argument lists is that:
  32. //
  33. //            o  Argument counting is done automagically
  34. //
  35. //            o  You get assertion checking of the number of
  36. //               arguments stuffed into the ArgList.
  37. //
  38.  
  39. #include <Xm/Xm.h>
  40.  
  41. #include <assert.h>
  42.  
  43. class OkArgs {
  44.     ArgList    _args;
  45.     Cardinal    _count;
  46.     Cardinal    _max;
  47.  
  48. public:
  49.     OkArgs(Cardinal max)
  50.         { _args = new Arg[max]; _max = max; _count = 0; }
  51.  
  52.     ~OkArgs()    { delete _args; }
  53.  
  54.     void set(String name, void* value)
  55.         {
  56.             assert(_count < _max);
  57.             XtSetArg(_args[_count], name, value);
  58.             _count++;
  59.         }
  60.  
  61.     void set(String name, int value)
  62.         {
  63.             assert(_count < _max);
  64.             XtSetArg(_args[_count], name, value);
  65.             _count++;
  66.         }
  67.  
  68.     void reset()
  69.         { _count = 0; }
  70.  
  71.     ArgList list()
  72.         { return _args; }
  73.  
  74.     Cardinal count()
  75.         { return _count; }
  76. };
  77.  
  78. #endif
  79.